module.exports = (app) => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;
  const ArticleSchema = new Schema(
    {
        title: {type: String, required: true},
        article: {type: String, required: true},
        // article_html: {type: String, required: true},
        coverImage: {type: String, required: false},
        views: {type: Number, required: false, default: 1},
        author: {
            type: Schema.Types.ObjectId,
            ref: "User",
            required: true,
        },
        category: {
            type: Schema.Types.ObjectId,
            ref: "Category",
            required: true,
        },
        like: {type: Number, required: false, default: 0}, // 赞
        dislike: {type: Number, required: false, default: 0}, // 踩
        commentCount: {type: Number, required: false, default: 0}, // 文章评论的数量
    },
    { timestamps: true }
  );
  return mongoose.model("Article", ArticleSchema);
};
